package com.ruoyi.web.controller.admin;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BdmGoodclassify;
import com.ruoyi.system.service.IBdmGoodclassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商品分类Controller
 * 
 * @author ruoyi
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/system/goodclassify")
public class BdmGoodclassifyController extends BaseController
{
    @Autowired
    private IBdmGoodclassifyService bdmGoodclassifyService;

    /**
     * 查询商品分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmGoodclassify bdmGoodclassify)
    {
        startPage();
        List<BdmGoodclassify> list = bdmGoodclassifyService.selectBdmGoodclassifyList(bdmGoodclassify);
        return getDataTable(list);
    }

    /**
     * 导出商品分类列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdmGoodclassify bdmGoodclassify)
    {
        List<BdmGoodclassify> list = bdmGoodclassifyService.selectBdmGoodclassifyList(bdmGoodclassify);
        ExcelUtil<BdmGoodclassify> util = new ExcelUtil<BdmGoodclassify>(BdmGoodclassify.class);
        util.exportExcel(response, list, "商品分类数据");
    }

    /**
     * 获取商品分类详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bdmGoodclassifyService.selectBdmGoodclassifyById(id));
    }

    /**
     * 新增商品分类
     */
    @PostMapping
    public AjaxResult add(@RequestBody BdmGoodclassify bdmGoodclassify)
    {
        return toAjax(bdmGoodclassifyService.insertBdmGoodclassify(bdmGoodclassify));
    }

    /**
     * 修改商品分类
     */
    @PutMapping
    public AjaxResult edit(@RequestBody BdmGoodclassify bdmGoodclassify)
    {
        return toAjax(bdmGoodclassifyService.updateBdmGoodclassify(bdmGoodclassify));
    }

    /**
     * 删除商品分类
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bdmGoodclassifyService.deleteBdmGoodclassifyByIds(ids));
    }
}
